import request from '@/utils/request'
const path = '/platform/app/'
const pathV2 = '/platform.app.addon/'

/**
 * 获取平台应用小程序的用户列表
 * @param page
 * @param size
 * @param search
 * @param plaid
 * @param refresh
 * @returns {*}
 */
export function getPlatformAppList(page = 0, size = 10, search = {}, plaid = 0, refresh) {
  return request({
    url: path + 'getPlatformAppList',
    method: 'post',
    data: { page, size, search, plaid, refresh }
  })
}

export function releasePlatformAppList(plaid) {
  return request({
    url: path + 'releasePlatformAppList',
    method: 'post',
    data: { plaid }
  })
}

export function getPlatformAppForm(id = 0, addon_name) {
  return request({
    url: path + 'getPlatformApprForm',
    method: 'post',
    data: { id, addon_name }
  })
}

/**
 * 添加应用小程序
 * @param aid
 * @param addon_name
 * @param plaid
 * @returns {AxiosPromise}
 */
export function addPlatformAddonApp(aid, addon_name, plaid) {
  return request({
    url: path + 'addPlatformAddonApp',
    method: 'post',
    data: { aid, addon_name, plaid }
  })
}

// /**
//  * 获取平台应用小程序表单
//  * @param id
//  * @param plaid
//  * @param is_admin
//  * @returns {AxiosPromise}
//  */
// export function getPlatformAddonAppForm(id = 0, plaid, is_admin = 0) {
//   return request({
//     url: path + 'getPlatformAddonAppForm',
//     method: 'post',
//     data: { id, plaid, is_admin }
//   })
// }

/**
 * 获取平台应用小程序表单
 * @param id
 * @param plaid
 * @returns {AxiosPromise}
 */
export function getPlatformAddonAppForm(id = 0, plaid) {
  return request({
    url: pathV2 + 'getPlatformAddonAppForm',
    method: 'post',
    data: { id, plaid }
  })
}
